// Load the components and engine objects
Engine.include("/components/component.transform2d.js");
Engine.include("/components/component.keyboardinput.js");
Engine.include("/engine/engine.object2d.js");

Engine.initObject("GoalArea", "Object2D", function() {
    
    var GoalArea = Object2D.extend({
	
	pos: Point2D.create(2,0),
	color: "#00ff00",		// The color of the object
	radius: 0.1,			// Our object's shapes
	
	constructor: function() {
            this.base("GoalArea");
	},
	
	/**
       * Update the object within the rendering context.  
       * This calls the transform
       * components to position the object on the playfield.
       *
       * @param renderContext {RenderContext} The rendering context
       * @param time {Number} The engine time in milliseconds
       */
	update: function(renderContext, time) {
	    renderContext.pushTransform();
	    
	    // The the "update" method of the super class
	    this.base(renderContext, time);
	    
	    // Draw the object on the render context
	    this.draw(renderContext);
	    
	    renderContext.popTransform();
	},
	
	/**
       * Get the position of the object from the transform component.
       * @return {Point2D}
       */
	getPosition: function() {
            return this.pos;
	},
	
	/**
       * Set the position of the object through transform component
       * @param point {Point2D} The position to draw the text in the playfield
       */
	setPosition: function(point) {
            this.pos = point;
	},
	
	/**
	 * Draw our unsafe area onto the specified render context.
	 * @param renderContext {RenderContext} The context to draw onto
	 */
	draw: function(renderContext) {
	    // Draw the unsafe area
	    renderContext.setFillStyle(this.color);
            renderContext.drawFilledCircle(this.pos, this.radius);
	}
	
    }, { // Static
	
	/**
       * Get the class name of this object
       * @return {String} The string MyObject
       */
	getClassName: function() {
            return "GoalArea";
	}
    });
    
    return GoalArea;
    
});
